package com.lpit.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
 * 搜索记录表
 * @TableName search_record
 */
@TableName(value ="search_record")
@Data
public class SearchRecord implements Serializable {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 外键（关联用户表的id）
     */
    private Integer userId;

    /**
     * 搜索的词条
     */
    private String searchTerm;

    /**
     * 搜索的日期时间
     */
    private Date searchDate;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SearchRecord other = (SearchRecord) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getSearchTerm() == null ? other.getSearchTerm() == null : this.getSearchTerm().equals(other.getSearchTerm()))
            && (this.getSearchDate() == null ? other.getSearchDate() == null : this.getSearchDate().equals(other.getSearchDate()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getSearchTerm() == null) ? 0 : getSearchTerm().hashCode());
        result = prime * result + ((getSearchDate() == null) ? 0 : getSearchDate().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", searchTerm=").append(searchTerm);
        sb.append(", searchDate=").append(searchDate);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}